package viper.diversity;


public class Diversity {
	int scheme;
	static byte  [] A;
	static byte  [] B;
	static byte  [] C;
	static byte  [] A_Xor_B;
	static byte  [] A_Xor_C;
	static byte  [] B_Xor_C;
	static byte  [] A_Xor_B_temp;
	static byte  [] A_Xor_C_temp;
	static byte  [] B_Xor_C_temp;
	static byte  [][] Two_Three_x = new byte[3][];
	static byte  [][] Four_Six_x;

	public static byte[][] diversify(byte [] one, byte [] two)
	{
		A_Xor_B_temp = new byte [one.length];
		for(int i=0;i<one.length;i++){
			A_Xor_B_temp [i]=(byte)(one[i]^two[i]);
		}
		A =  new byte[one.length];
		//A[0]=0;
		System.arraycopy(one,0,A,0,one.length);
		B =  new byte[two.length];
		//B[0]=1;
		System.arraycopy(two,0,B,0,two.length);
		A_Xor_B = new byte[A_Xor_B_temp.length];
		//A_Xor_B[0]= 3;
		System.arraycopy(A_Xor_B_temp,0,A_Xor_B,0,A_Xor_B_temp.length);
		Two_Three_x[0]=A;
		Two_Three_x[1]=B;
		Two_Three_x[2]=A_Xor_B;
		return Two_Three_x;
	}
	public static byte [][] diversify(byte [] one, byte [] two, byte [] three){
		A_Xor_B_temp = new byte [one.length];
		A_Xor_C_temp = new byte [two.length];
		B_Xor_C_temp = new byte [three.length];
		for(int i=0;i<one.length;i++){
			A_Xor_B_temp [i]=(byte)(one[i]^two[i]);
		}
		for(int i=0;i<two.length;i++){
			A_Xor_C_temp [i]=(byte)(one[i]^three[i]);
		}
		for(int i=0;i<two.length;i++){
			B_Xor_C_temp [i]=(byte)(two[i]^three[i]);
		}
		A =  new byte[one.length+1];
		A[0]=0;
		System.arraycopy(one,0,A,1,one.length);
		B =  new byte[two.length+1];
		B[0]=1;
		System.arraycopy(two,0,B,1,two.length);
		C =  new byte[three.length+1];
		C[0]=2;
		System.arraycopy(three,0,C,1,three.length);
		A_Xor_B = new byte[A_Xor_B.length+1];
		A_Xor_B[0]= 3;
		System.arraycopy(A_Xor_B_temp,0,A_Xor_B,1,A_Xor_B_temp.length);
		A_Xor_C = new byte[A_Xor_C.length+1];
		A_Xor_C[0]= 4;
		System.arraycopy(A_Xor_C_temp,0,A_Xor_C,1,A_Xor_C_temp.length);
		B_Xor_C = new byte[B_Xor_C.length+1];
		B_Xor_C[0]= 5;
		System.arraycopy(B_Xor_C_temp,0,B_Xor_C,1,B_Xor_C_temp.length);
		Four_Six_x[0]=A;
		Four_Six_x[1]=B;
		Four_Six_x[2]=C;
		Four_Six_x[3]=A_Xor_B;
		Four_Six_x[4]=A_Xor_C;
		Four_Six_x[5]=B_Xor_C;
		return Four_Six_x;	
	}

}


